package com.pai4j.common.enums.community;

import com.chat4j.common.exception.ParamException;
import lombok.Getter;

/**
 * @Author: 程序员七七
 * @Date: 25.12.21 1:12 上午
 */
@Getter
public enum ResourcePayTypeEnum {

    FREE(1, "免费"),

    COIN(2, "猿气值"),

    MONEY(3, "金额");

    private Integer type;

    private String desc;

    ResourcePayTypeEnum(Integer type, String desc) {
        this.type = type;
        this.desc = desc;
    }

    public static boolean isFree(Integer type) {
        return FREE.type.equals(type);
    }

    public static boolean isCoin(Integer type) {
        return COIN.type.equals(type);
    }

    public static boolean isMoney(Integer type) {
        return MONEY.type.equals(type);
    }


    public static void validPayType(int payType) {
        for (ResourcePayTypeEnum resourcePayTypeEnum : ResourcePayTypeEnum.values()) {
            if (resourcePayTypeEnum.type == payType) {
                return;
            }
        }
        throw new ParamException("不支持的支付方式");
    }

    public static String getPrintPayType(Integer payType) {
        for (ResourcePayTypeEnum resourcePayTypeEnum : ResourcePayTypeEnum.values()) {
            if (resourcePayTypeEnum.type == payType) {
                return resourcePayTypeEnum.getDesc();
            }
        }
        return "未知";
    }
}
